<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <div>
       <h1>The Ajax 01 Page</h1>
       <button  onclick="doAjaxStart()">Ajax Get Request Start</button>
       <span id="result"></span>
   </div>
 <script>
     function doAjaxStart(){
         //1.create xhr对象
         let xhr =new XMLHttpRequest();
         //2.设置状态监听
         xhr.onreadystatechange=function () {
            if (xhr.readyState==4){
                if (xhr.status==200){
                    let result = xhr.responseText;
                    document.getElementById("result").innerHTML=result;
                }
            }
         }
         //3.建立一个与服务端指定url的链接
         let url="http://localhost/doAjaxStart";
         xhr.open("Get",url,true);
         //4.发送请求-
         xhr.send(null);//这个请求交给谁去发送？（ajax引擎）
         console.log("===main====")
     }
 </script>

</body>
</html>